/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package reader;

import java.io.BufferedReader;
import java.io.IOException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import org.json.JSONObject;

/**
 *
 * @author tae
 */
public class RequestReader {
    public static JSONObject requestToJSONObject(HttpServletRequest request) throws IOException 
    {
        BufferedReader reader=request.getReader();
        
        System.out.println("start");
        
        
        String returnMsg="";
        
        while(true)
        {
            String temp=reader.readLine();
            if(temp==null)
                break;
            System.out.println("temp : "+temp);
            returnMsg+=temp;
        }
        
        System.out.println("returnMsg : "+returnMsg.trim());
        
        System.out.println("end");
        
        return new JSONObject(returnMsg.trim());
    }
}
